home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Atari Compendium
/
The Atari Compendium (Toad Computers) (1994).iso
/
files
/
umich
/
tex
/
td187src.lzh
/
DIALOGE.I
< prev
next >
Wrap
Text File
|
1991-12-14
|
45KB
|
1,323 lines
IMPLEMENTATION MODULE Dialoge;
IMPORT CommonData;
IMPORT mtAppl;
IMPORT mtDials;
IMPORT mtRsc;
IMPORT mtAlerts;
IMPORT MagicAES;
IMPORT MagicVDI;
IMPORT MagicConvert;
IMPORT MagicStrings;
IMPORT MagicSys;
IMPORT VectorFont;
FROM SYSTEM IMPORT ADDRESS , ADR ;
FROM Types IMPORT DrawObjectTyp, ObjectRecTyp, Block,
sourceformat, targetformat,
LatexSpecials,
TextPosTyp, ObjectPtrTyp;
FROM Variablen IMPORT UnitToStr,
FirstObject, LastObject,
NewObject, DeleteObject,
RefObject, Position,
zoomfak,
CoordToStr;
IMPORT GetFile;
IMPORT RSCindices;
IMPORT Diverses;
(**
IMPORT RTD;
**)
VAR Tree : POINTER TO ARRAY [0..200] OF MagicAES.OBJECT;
PROCEDURE OpenForm(form: mtDials.DIALOG);
BEGIN
IF Diverses.DialCentered THEN
mtDials.DialCenter (form, mtDials.CSCREEN, 0, 0);
ELSE
mtDials.DialCenter (form, mtDials.CMOUSE, 0, 0);
END;
mtDials.DialForm (form, mtDials.DSTART);
mtDials.DialForm (form, mtDials.DGROW);
mtDials.DialDraw (form, 0, 999);
END OpenForm;
PROCEDURE CloseForm(form: mtDials.DIALOG);
BEGIN
mtDials.DialForm (form, mtDials.DSHRINK);
mtDials.DialForm (form, mtDials.DFINISH);
END CloseForm;
PROCEDURE NormalizeForm(form: mtDials.DIALOG; index : INTEGER);
BEGIN
IF index>0 THEN
mtDials.ExclState (form, index, MagicAES.SELECTED);
END;
END NormalizeForm;
PROCEDURE DoForm (form: mtDials.DIALOG; start : INTEGER) : INTEGER;
VAR i: INTEGER;
BEGIN
OpenForm(form);
i:= mtDials.DialDo (form, start);
CloseForm(form);
NormalizeForm(form, i);
RETURN i;
END DoForm;
PROCEDURE DrawDeskIcon(Icon : INTEGER);
CONST DeskWin = 0 ;
VAR brec, bvis, bsect : Block;
tree : POINTER TO ARRAY [ 0..255 ] OF MagicAES.OBJECT ;
BEGIN
tree := MagicAES.RsrcGaddr( MagicAES.RTREE , RSCindices.desktop ) ;
MagicAES.ObjcOffset ( tree , Icon , brec.x , brec.y ) ;
brec.w := tree^ [ Icon ] .obWidth ;
brec.h := tree^ [ Icon ] .obHeight ;
(* Zuerst holen wir uns mal den sichtbaren Bereich *)
MagicAES.WindGet(DeskWin, MagicAES.WFFIRSTXYWH, bvis);
WHILE (bvis.w > 0) AND (bvis.h > 0) DO
IF Diverses.BlockIntersect(brec, bvis, bsect) THEN
MagicAES.ObjcDraw ( tree , 0 , 9 , bsect);
END ;
MagicAES.WindGet(DeskWin, MagicAES.WFNEXTXYWH, bvis);
END ;
END DrawDeskIcon;
PROCEDURE DeselectIcon ( Icon : INTEGER ) ;
VAR rec : RECORD x , y , w , h : INTEGER ; END;
tree : POINTER TO ARRAY [ 0..255 ] OF MagicAES.OBJECT ;
BEGIN
IF Icon >= 0 THEN
tree := MagicAES.RsrcGaddr( MagicAES.RTREE , RSCindices.desktop ) ;
EXCL(tree^[Icon].obState, MagicAES.SELECTED);
MagicAES.ObjcOffset ( tree , Icon , rec.x , rec.y ) ;
DrawDeskIcon(Icon);
END;
END DeselectIcon;
PROCEDURE SelectIcon ( Icon : INTEGER ) ;
VAR rec : RECORD x , y , w , h : INTEGER ; END;
tree : POINTER TO ARRAY [ 0..255 ] OF MagicAES.OBJECT ;
BEGIN
IF Icon >= 0 THEN
tree := MagicAES.RsrcGaddr( MagicAES.RTREE , RSCindices.desktop ) ;
INCL(tree^[Icon].obState, MagicAES.SELECTED);
DrawDeskIcon(Icon);
END;
END SelectIcon;
PROCEDURE GetBut(dial : mtDials.DIALOG; start, ende : INTEGER) : INTEGER;
VAR ind : INTEGER ;
BEGIN
ind := start;
WHILE ind<=ende DO
(* Alle Radio-Buttons einer Ebene *)
IF mtDials.InFlag(dial, ind, MagicAES.RBUTTON) THEN
IF mtDials.InState(dial, ind, MagicAES.SELECTED) THEN
RETURN ind
END;
END;
INC(ind, 1);
END;
RETURN -1;
END GetBut;
PROCEDURE SetBut(dial : mtDials.DIALOG; start, ende, set : INTEGER);
VAR ind, old : INTEGER ;
BEGIN
(*
PDebug.ShowWord('SetBut from:', start);
PDebug.ShowWord('SetBut to :', ende);
PDebug.ShowWord('SetBut set :', set);
*)
old := GetBut(dial, start, ende);
(* Wir müssen erst einen eventuell vorhan- *)
(* denen Radio-Button zurücksetzen ! *)
FOR ind := start TO ende DO
(* Alle Radio-Buttons einer Ebene *)
IF mtDials.InFlag(dial, ind, MagicAES.RBUTTON) THEN
NormalizeForm(dial, ind);
END;
END;
IF (set>=0) OR (old<start) OR (old>ende) THEN
IF (ABS(set)>=start) AND (ABS(set)<=ende) THEN
IF mtDials.InFlag(dial, ABS(set), MagicAES.RBUTTON) THEN
mtDials.InclState(dial, ABS(set), MagicAES.SELECTED);
END;
END;
ELSE
IF mtDials.InFlag(dial, old, MagicAES.RBUTTON) THEN
mtDials.InclState(dial, old, MagicAES.SELECTED);
END;
END;
END SetBut;
PROCEDURE BlankToZero(VAR text : ARRAY OF CHAR);
VAR i : INTEGER;
BEGIN
i := 0;
WHILE (text[i]=' ') DO
text[i] := '0';
INC(i);
END;
END BlankToZero;
PROCEDURE GetUnitLength(VAR newfak, newunit : INTEGER;
VAR zoom : BOOLEAN) : BOOLEAN;
(* Bestimme Einheit der Unitlength *)
VAR but, i, j : INTEGER ;
k, l : INTEGER ;
x, y, w, h: INTEGER ;
oldunit,
oldfak : INTEGER ;
Dial : mtDials.DIALOG;
res : BOOLEAN;
BEGIN
(* Geht davon aus, daß die Buttons unmittelbar aufeinanderfolgen.
Also bitte beachten bei Änderung des RSC-Files !!!
*)
res := FALSE;
Tree := mtRsc.GaddrRsc(RSC, MagicAES.RTREE , RSCindices.unitlen ) ;
IF mtDials.NewDial(Tree, Dial) THEN
oldunit := FirstObject^.Code[6] MOD 0100H;
oldfak := FirstObject^.Code[6] DIV 0100H;
SetBut(Dial, RSCindices.mmunit, RSCindices.ppunit,
RSCindices.mmunit + oldunit);
CASE oldfak OF
0 : (* x 1 *) i := 2; |
1 : (* x 1/10 *) i := 1; |
2 : (* x 10 *) i := 3; |
3 : (* x 1/100 *) i := 0; |
4 : (* x 100 *) i := 4; |
ELSE
(* sollte nicht vorkommen *)
i := 2;
END;
SetBut(Dial, RSCindices.fak01100, RSCindices.fak10001,
RSCindices.fak01100 + i);
NormalizeForm (Dial, RSCindices.zyes);
but := DoForm ( Dial , -1 ) ;
IF but<>RSCindices.cancel THEN
res := TRUE;
newunit := GetBut(Dial, RSCindices.mmunit, RSCindices.ppunit);
i := GetBut(Dial, RSCindices.fak01100, RSCindices.fak10001);
zoom := mtDials.InState(Dial, RSCindices.zyes, MagicAES.SELECTED);
IF newunit=-1 THEN
newunit := RSCindices.mmunit; (* Sicherheitshalber, falls was schiefgeht *)
END;
IF i=-1 THEN
i := RSCindices.fak01100 + 2; (* Sicherheitshalber, falls was schiefgeht *)
END;
i := i - RSCindices.fak01100;
CASE i OF
0 : (* x 1/100 *) newfak := 3; |
1 : (* x 1/10 *) newfak := 1; |
2 : (* x 1 *) newfak := 0; |
3 : (* x 10 *) newfak := 2; |
4 : (* x 100 *) newfak := 4; |
ELSE
(* sollte nicht vorkommen *)
newfak := 0;
END;
newunit := newunit - RSCindices.mmunit;
END;
mtDials.DisposeDial(Dial);
END;
RETURN res;
END GetUnitLength;
PROCEDURE ChangeObjSize ( VAR xmal, ymal : LONGREAL );
VAR Dial : mtDials.DIALOG;
ok : BOOLEAN;
x0, y0, w,
h, but : INTEGER ;
xtxt, ytxt : ARRAY [0..127] OF CHAR;
BEGIN
Tree := mtRsc.GaddrRsc(RSC, MagicAES.RTREE , RSCindices.skaliere ) ;
IF mtDials.NewDial(Tree, Dial) THEN
xtxt := '0100';
ytxt := '0100';
Tree^[RSCindices.xfactor].TedPtr^.tePtext := ADR(xtxt);
Tree^[RSCindices.yfactor].TedPtr^.tePtext := ADR(ytxt);
(* Eigentlich hätte ich erwartet, daß man die Textlänge 4 übergeben *)
(* muss, daß hat auch sonst funktioniert. Nur bei der MagicLib muß *)
(* hier ein um 1 höherer Wert angegeben werden!! Eventueller Bug ?? *)
Tree^[RSCindices.xfactor].TedPtr^.teTxtlen := 5;
Tree^[RSCindices.yfactor].TedPtr^.teTxtlen := 5;
but := DoForm(Dial, RSCindices.xfactor);
mtDials.DisposeDial(Dial);
xmal := 0.0;
ymal := 0.0;
IF but=RSCindices.skweiter THEN
xmal := MagicConvert.StrToReal(xtxt);
ymal := MagicConvert.